#ifndef __HEADER_TCP_COMMON__
#define __HEADER_TCP_COMMON__
#include "crypto/types.h"
#include "crypto/json.h"
#include "crypto/parse/json/ParseJsonImp.h"
#include "crypto/des.h"
#include "crypto/md5.h"

Json *TCPApplicationData(byte *data, int len, byte *desKey);

struct user
{
    int fd;
    char nickName[20];
    // if use inet_ntop, can store ip instead use inet_ntoa
    char ip[20];
    byte desKey[8];
    struct user *next;
    struct sockaddr_in *clientAddr;
};

typedef struct user User;

enum TCP_RESPONSE_CODE
{
    TCP_RESPONSE_SUCCESS = 200,
    TCP_RESPONSE_CHECK_FAIL = 400,
    TCP_RESPONSE_DATA_FAIL = 401,
    TCP_RESPONSE_DECODE_FAIL = 400,
};

int TCPResponse(enum TCP_RESPONSE_CODE code, byte *desKey, byte *buffer);

int TCPSend(byte *data, int len, byte *desKey, byte *buffer);
// already check the md5 number
Json *TCPReceive(byte *data, int len, byte *desKey);

#endif
